package com.wcpdoc.exam.api.controller;

import com.wcpdoc.core.controller.BaseController;
import com.wcpdoc.core.entity.PageResult;
import com.wcpdoc.exam.core.entity.ExmMyExer;
import com.wcpdoc.exam.core.service.ExmMyExerService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
@RequestMapping("/api/exmMyExer")
public class ApiExmMyExerController extends BaseController {

    @Resource
    ExmMyExerService exmMyExerService;

    @RequestMapping("/save")
    @ResponseBody
    public PageResult save(ExmMyExer exmMyExer){
        exmMyExer.setUserId(getCurUser().getId());
        exmMyExer.setContent(exmMyExer.getContent().replace("&quot;", "\""));
        return exmMyExerService.save(exmMyExer);
    }

    @RequestMapping("/get")
    @ResponseBody
    public PageResult get(Integer type){
        return exmMyExerService.get(getCurUser().getId(),type);
    }
}
